﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DoubanApiLib.Base
{
    /// <summary>
    /// 封装运行时信息
    /// </summary>
    public sealed class Runtime
    {
        /// <summary>
        /// 系统运行参数
        /// </summary>
        public sealed class SystemParam
        {
            /// <summary>
            /// API Key
            /// </summary>
            public const string API_KEY = "0c30ba2679e510e824922e736daf32b8";
            /// <summary>
            /// 私钥
            /// </summary>
            public const string API_KEY_SECRET = "a72d3ee1230f90ef";
        }

        #region API地址

        /// <summary>
        /// 封装豆瓣API地址
        /// </summary>
        public sealed class Api
        {
            /// <summary>
            /// OAuth认证相关API 
            /// </summary>
            public class OAuth
            {
                public const string RequestTokenURI = "http://www.douban.com/service/auth/request_token";
                public const string RequestTokenURI_PARAM = "?oauth_consumer_key={0}&oauth_nonce={1}&oauth_timestamp={2}"
                                                     + "&oauth_signature_method={3}&oauth_version={4}&oauth_signature={5}";
                
                public const string AuthorizationURI = "http://www.douban.com/service/auth/authorize";
                public const string AuthorizationURI_PARAM = "?oauth_token={0}";

                public const string AccessTokenURI = "http://www.douban.com/service/auth/access_token";
                public const string AccessTokenURI_PARAM = "?oauth_consumer_key={0}&oauth_nonce={1}&oauth_timestamp={2}"
                                                     + "&oauth_signature_method={3}&oauth_version={4}&oauth_signature={5}&oauth_token={6}";
            }

            /// <summary>
            /// 用户信息相关API
            /// </summary>
            public class Account
            {
                /// <summary>
                /// 获取用户信息
                /// </summary>
                public const string GetUserInfo="http://api.douban.com/people/{0}";

                /// <summary>
                /// 获取授权用户信息
                /// </summary>
                public const string GetOAuthUserInfo = "http://api.douban.com/people/%40me";

                /// <summary>
                /// 搜索用户 拼接参数 全文检索的关键词 起始元素 返回结果的数量
                /// </summary>
                public const string SelectUsersInfo = "http://api.douban.com/people?q={0}&start-index={1}&max-results={2}";

                /// <summary>
                /// 获得用户朋友 {userID}
                /// </summary>
                public const string GetUserFriends = "http://api.douban.com/people/{0}/friends?start-index={1}&max-results={2}";
            }
        }

        #endregion

        #region 其他
        /// <summary>
        /// 公共消息参数
        /// </summary>
        public class MessageParam
        {
            /// <summary>
            /// 空
            /// </summary>
            public const string UNDEFINE = "undefine";
        }

        /// <summary>
        /// 调试使用
        /// </summary>
        public sealed class Debug
        {
            /// <summary>
            /// 输出信息
            /// </summary>
            /// <param name="message"></param>
            public static void Write(string message)
            {
                Debug.Write(message);
            }

            /// <summary>
            /// 输出一行信息
            /// </summary>
            /// <param name="message"></param>
            public static void WriteLine(string message)
            {
              System.Diagnostics.Debug.WriteLine(message);
            }

            /// <summary>
            /// 条件成立则输出一行信息
            /// </summary>
            /// <returns></returns>
            public static void Assist(bool flag,string message)
            {
                if (flag)
                {
                    System.Diagnostics.Debug.WriteLine(message);
                }
            }
        }
        #endregion 
    }
}
